<template>
  <view>
    
<!--    <view class="image-box">
      <image src="/static/images/对号2.png" mode="widthFix"></image>
    </view>
    
    <view class="sucesshead">认证完成</view>
    
    <view class="sucessText">恭喜您! 完成身份认证</view> -->
    
    <my-authentication :myType="myType"></my-authentication>
    
    <button class="upload-but"  type="default" @click="navTo">{{myType == 1 ? '返回' : '重试'}}({{sec}})</button>
    
  </view>
</template>

<script>
  export default {
    data() {
      return {
        sec: 3,
        timer: null,
        myType: 1,
        result: 1,
        salaryId: null
      };
    },
    created() {
      this.countdown(this.sec)
    },
    onLoad(options) {
      console.log('succuse',options);
      this.salaryId = options.salaryId
      this.myType = options.type  // 1就是成功 0就是失败
      
      if(this.myType == 1){
        console.log('发起薪资确认请求 请求的salaryID为: ', this.salaryId);
        uni.$put(this.path + '/salary/audit',[
           {
              id: parseInt(this.salaryId), 
              isChecked: 2,       //无论1还是2都是未确认只有3是已确认，个人薪资确认
              permissionFlag: '',
              salaryAdd: '',
              salaryAll: '',
              salaryBase: '',
              salaryDate: '',
              salaryPersonIdentityCard: '',
              salaryRelativePerson:'',
              salaryRelativeProjectId: 0,
              salaryRemarks: '',
              flag:  uni.getStorageSync('usertype') == 3?8:9
            }
        ]).then(res => {
          console.log('que',res);
        })
      }
      
      
    },
    methods:{
      countdown(seconds) {
        if (seconds <= 0) {
          console.log("倒计时结束！");
          this.navTo()
        } else {
          console.log(`倒计时剩余 ${seconds} 秒`);
          this.sec = seconds
          this.timer = setTimeout(() => {
            this.countdown(seconds - 1);
          }, 1000); // 1秒后再次调用countdown函数
        }
      },
      navTo(){
        console.log('定时器销毁');
        clearTimeout(this.timer);
        uni.navigateBack({
          url: './index'
        })
      },
      onUnload(){
        console.log('定时器销毁');
        clearTimeout(this.timer);
      }
    }
  }
</script>

<style lang="scss">
  .sucesshead{
    color: black;
    font-size: 32rpx;
    text-align: center;
    margin-top: 32rpx;
  }
  
  .sucessText{
    margin-top: 21rpx;
    text-align: center;
    color: #999;
  }
  
  .upload-but{
    margin-top: 126rpx;
    background-color: #055dfe !important;
    color: white !important;
    width: 90%;
  }
  .image-box{
    padding-top: 65rpx;
    display: flex;
    justify-content: center;
    align-items: center;
    image{
      height: 164rpx;
      width: 164rpx;
    }
  }
  
  page{
    background-color: #f6f9fc;
  }
</style>
